package com.example.orderform.dao;

import com.example.orderform.vo.ADDress;
import com.example.orderform.vo.Order;
import com.example.orderform.vo.Shi;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;

@Mapper
@Repository
public interface AllOrderMapper {

    @Select("SELECT * FROM order_copy1  where deletestate=1 and userid='${userid}' and orderid LIMIT #{q},#{j}")
    List<Order> syselectorder(int userid,int q,int j);

    @Select("select count(*) from order_copy1 where userid=${userid}")
    int he(int userid);

    @Select("SELECT * FROM order_copy1 where orderstatus=#{orderstatus} and userid=${userid}")
    List<Order> mohuselect(String orderstatus,int userid);

    @Update("UPDATE order_copy1 SET `deletestate` = '0' WHERE `orderid` = #{orderid}")
    int update(int orderid);


    @Insert("INSERT INTO `order_copy1`( `userid`,`spid`,`ordernumber`,`undertime`,`payway`,`paytime`,`logisticscompany`,`couriernumber`,`orderstatus`,`comitydescription`,`comityprices`,`comitynumber`,`comitypicture`,`Settlementprice`,`addressinformation`,`freight`,`actualpayment`,`preferentialinformation`,`deletestate`,`specifications`,`statusbutton`,`statusbuttonunder`,`consignee`,`telephone`) " +
            "VALUES (#{userid}, #{spid}, #{ordernumber}, #{undertime}, #{payway}, #{paytime}, #{logisticscompany},#{couriernumber}, #{orderstatus}, #{comitydescription}, #{comityprices},#{comitynumber}, #{comitypicture},#{Settlementprice}, #{addressinformation}, #{freight},#{actualpayment},#{preferentialinformation}, #{deletestate}, #{specifications}, #{statusbutton},#{statusbuttonunder}, #{consignee},#{telephone})")
    int orderinsert(int userid, int spid, String ordernumber, Date undertime, String payway, Date paytime, String logisticscompany, String couriernumber, String orderstatus, String comitydescription, double comityprices, int comitynumber, String comitypicture, double Settlementprice, String addressinformation, String freight, double actualpayment, String preferentialinformation, String deletestate, String specifications, String statusbutton, String statusbuttonunder,String consignee,String telephone);

    @Select("SELECT * FROM order_copy1  where undertime like '%#{undertime}%' and ordernumber like '%#{ordernumber}%'  ")
    List<Order> selbyorder(String undertime, String ordernumber);

    @Select("select * from address where addressid=${addressid}")
    ADDress address(int addressid);
}
